package units
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	import projectiles.Yellow_Projectile;
	
	public class Yellow_Unit extends Unit
	{
		
		public function Yellow_Unit(gH:GameHandler,c:Castle)
		{
			super.game_handler = gH;
			super.castle = c;
			
			unit_type = "yellow_unit";
			range_line_style = 0xE9F745;
			
			this.attack_strength = .1;
			this.attack_radius = 300;
			this.attack_frequency = 1;
			
			game_handler.player_units.push(this);
			game_handler.addChild(this);

			this.addEventListener(MouseEvent.MOUSE_DOWN,super.select);
			
			show_range();
			hide_range();
		}
		var last_target = 0;
		override public function attack(){
			if(attack_counter < attack_frequency)
				return;
			var valid_targets:Array = get_valid_targets();
			for(var i = 0; i < 2; i++){
				if(valid_targets.length != 0){
					attack_counter = 0;
					if(valid_targets.length <= last_target)
						last_target = 0;
					if(valid_targets[last_target] == null)
						continue;
					var p:Yellow_Projectile = new Yellow_Projectile(this,valid_targets[last_target],game_handler,this.attack_strength);
					valid_targets[last_target].virtual_hit("yellow",this.attack_strength);
					p.set_attack_damage(this.attack_strength);
					p.set_speed(10);
				}
				last_target ++;
			}
		}
		
	}
}